#include <sstream>
#include <xscript/xerror.h>
#include <xscript/xprint.h>

XError::XError() {
}

void XError::setError(XError_Enum type, const std::wstring& message) {
    errorType = type;
    errorString = message;
}

void XError::setError(XError_Enum type, const std::wstring& module, uint32_t line, const std::wstring& variable) {
    errorType = type;
    std::wstringstream stream;
    stream << "module:" << module;
    stream << ",line:" << line;
    stream << ",variable:" << variable;
    errorString = stream.str();
}

std::wstring XError::getErrorInfo() const {
    if (!hasError())
        return L"execute success";

    std::wstringstream stream;
    stream << L"error type:" << errorType;
    stream << ",message:" << errorString;
    return stream.str();
}
